//
//  RCFMDataBaseManager.m
//  RCDataBaseProjecat
//
//  Created by Roiy on 2017/7/31.
//  Copyright © 2017年 Roiy. All rights reserved.
//

#import "RCFMDataBaseManager.h"
#import "FMDatabase.h"

@interface RCFMDataBaseManager()

@property (nonatomic,strong)FMDatabase *fmDataBase;

@end

@implementation RCFMDataBaseManager

+(instancetype)databaseWithPath:(NSString *)aPath
{
    return [[self alloc] initWithPath:aPath];
}

-(instancetype)initWithPath:(NSString *)path
{
    self = [super initWithPath:path];
    if (self) {
        
    }
    return self;
}

-(FMDatabase *)fmDataBase
{
    if (!_fmDataBase)
    {
        _fmDataBase =[FMDatabase databaseWithPath:self.dataBasePath];
    }
    return _fmDataBase;
}

#pragma ---DataBase Operation Protocal--
-(BOOL)openDB
{
    
    return [self.fmDataBase open];
}

-(BOOL)closeDB
{
    return [self.fmDataBase close];
}

-(BOOL)executeHandle:(NSString *)sql, ...
{
    return [self.fmDataBase executeUpdate:sql];
}

-(id)executeQuery:(NSString *)sql, ...
{
    return [self.fmDataBase executeQuery:sql];
}

@end
